package com.evil.application.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.evil.application.mapper.ApplicationFormMapper;
import com.evil.application.pojo.dto.form.CopyAppFormReqDTO;
import com.evil.application.pojo.dto.form.control.save.CopyControlDTO;
import com.evil.application.pojo.entity.ApplicationForm;
import com.evil.application.pojo.entity.ApplicationInfo;
import com.evil.common.application.dto.ApplicationIdVersionReqDTO;
import com.evil.common.application.dto.ApplicationIdsVersionReqDTO;
import com.evil.common.core.dto.FindByIdsReqDTO;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * 应用表单表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface ApplicationFormService extends IService<ApplicationForm> {

    @Override
    ApplicationFormMapper getBaseMapper();

    /**
     * 应用表单
     *
     * @param id id
     */
    Optional<ApplicationForm> isExistById(Long id);

    /**
     * 应用表单
     *
     * @param id id
     */
    ApplicationForm findById(Long id);

    /**
     * 应用表单
     *
     * @param applicationIdVersionReqDTO applicationIdVersionReqDTO
     */
    ApplicationForm findByAppIdAndVersion(ApplicationIdVersionReqDTO applicationIdVersionReqDTO);

    /**
     * 应用表单列表
     *
     * @param findByIdsReqDTO findByIdsReqDTO
     */
    List<ApplicationForm> findByIds(FindByIdsReqDTO findByIdsReqDTO);

    /**
     * 应用表单列表
     *
     * @param applicationIdsVersionReqDTO applicationIdsVersionReqDTO
     */
    List<ApplicationForm> findByAppIdsAndVersion(ApplicationIdsVersionReqDTO applicationIdsVersionReqDTO);

    /**
     * 应用表单列表
     *
     * @param findByIdsReqDTO findByIdsReqDTO
     */
    Map<Long, ApplicationForm> findMapByIds(FindByIdsReqDTO findByIdsReqDTO);

    /**
     * 发布版表单
     *
     * @param appId appId
     * @return ApplicationForm
     */
    ApplicationForm releaseForm(Long appId);

    /**
     * 发布版表单
     *
     * @param app app
     * @return ApplicationForm
     */
    ApplicationForm releaseForm(ApplicationInfo app);

    /**
     * 初始化应用表单
     *
     * @param applicationInfo applicationInfo
     */
    void initForm(ApplicationInfo applicationInfo);

    /**
     * 发布应用表单
     *
     * @param applicationInfo applicationInfo
     * @return CopyControlRespDTO
     */
    CopyControlDTO publishApplicationForm(ApplicationInfo applicationInfo);

    /**
     * 还原应用表单
     *
     * @param applicationInfo applicationInfo
     * @return CopyControlRespDTO
     */
    CopyControlDTO restoreApplicationForm(ApplicationInfo applicationInfo);

    /**
     * 删除应用表单
     *
     * @param applicationInfo applicationInfo
     */
    void deleteForm(ApplicationInfo applicationInfo);

    /**
     * 复制应用表单
     *
     * @param copyAppFormReqDTO copyAppFormReqDTO
     * @return 不同版本新旧表单控件id映射
     */
    Map<Integer, Map<Long, Long>> copyApplicationForm(CopyAppFormReqDTO copyAppFormReqDTO);

}
